import UIKit

@available(iOS 5.0, *)
extension QKC where AA :UIDocument {
	// Clients that wish to access these properties outside of an open, save, or revert completion handler and wait for any pending file operations should wrap the accesses in -performAsynchronousFileAccessUsingBlock:
    open func fileURL_qk_g() -> QKC<AA,YY,ZZ, URL >{
		 self +^ self.value.fileURL
	}

		// The default implementation derives the name from the URL. Subclasses may override to provide a custom name for presentation to the user, such as in error strings.
    open func localizedName_qk_g() -> QKC<AA,YY,ZZ, String >{
		 self +^ self.value.localizedName
	}

		// The file's UTI. Derived from the fileURL by default.
    open func fileType_qk_g() -> QKC<AA,YY,ZZ, String? >{
		 self +^ self.value.fileType
	}

		// The last known modification date of the document's on-disk representation. Updated by openWithCompletionHandler:, revertToContentsOfURL:, and saveToURL: and will return nil if none of these has completed successfully at least once.
    open func fileModificationDate_qk_s(_ fileModificationDate:  Date? ) -> QKC<AA,YY,ZZ, Date? >{
		return link(next: fileModificationDate).then_QK { $0.value.fileModificationDate = fileModificationDate }
	}
    open func fileModificationDate_qk_g() -> QKC<AA,YY,ZZ, Date? >{
		 self +^ self.value.fileModificationDate
	}

    open func documentState_qk_g() -> QKC<AA,YY,ZZ, UIDocument.State >{
		 self +^ self.value.documentState
	}

		// The download or upload progress of a document. Valid while UIDocumentStateProgressAvailable is set.
    @available(iOS 9.0, *)
    open func progress_qk_g() -> QKC<AA,YY,ZZ, Progress? >{
		 self +^ self.value.progress
	}

	// Typically, when a subclass sets the undoManager, it does not need to override -hasUnsavedChanges or call updateChangeCount: manually.
    open func undoManager_qk_s(_ undoManager:  UndoManager) -> QKC<AA,YY,ZZ, UndoManager>{
		return link(next: undoManager).then_QK { $0.value.undoManager = undoManager }
	}
    open func undoManager_qk_g() -> QKC<AA,YY,ZZ, UndoManager>{
		 self +^ self.value.undoManager
	}

	// The default implementation of -autosaveWithCompletionHandler: initiates a save if [self hasUnsavedChanges] is YES.
    open func hasUnsavedChanges_qk_g() -> QKC<AA,YY,ZZ, Bool >{
		 self +^ self.value.hasUnsavedChanges
	}

		// The default implementation returns the current file type. saveToURL: will save to an extension based on this type so subclasses can override this to allow moving the document to a new type.
    open func savingFileType_qk_g() -> QKC<AA,YY,ZZ, String? >{
		 self +^ self.value.savingFileType
	}

	// Open the document located by the fileURL.  This will call readFromURL:error: on a background queue and then invoke the completionHandler on the current dispatch queue when openWithCompletionHandler: is invoked.
    open func open_qk_f(completionHandler: ((Bool) -> Void)? = nil) -> QKC<AA,YY,ZZ,Void>{
		 self +^ self.value.open(completionHandler:completionHandler)
	}

	// Close the document. The default implementation calls [self autosaveWithCompletionHandler:completionHandler] which will save if [self hasUnsavedChanges] returns YES.
    open func close_qk_f(completionHandler: ((Bool) -> Void)? = nil) -> QKC<AA,YY,ZZ,Void>{
		 self +^ self.value.close(completionHandler:completionHandler)
	}

	// typeName is the UTI of the loaded file.
    open func load_qk_f(fromContents contents: Any, ofType typeName: String?) -> QKC<AA,YY,ZZ, Any>{
		 self +^ (try?self.value.load(fromContents:contents, ofType:typeName)) +^ contents
	}

	// Subclasses that return something other than a valid NSFileWrapper or NSData instance, or don't override this method must override one of the writing methods in the Advanced Saving section to write data to disk.
    open func contents_qk_f(forType typeName: String) -> QKC<AA,YY,ZZ,Any?>{
		 self +^ (try?self.value.contents(forType:typeName))
	}

	// The default implementation of these methods do nothing.
    open func disableEditing_qk_f() -> QKC<AA,YY,ZZ,Void>{
		 self +^ self.value.disableEditing()
	}

    open func enableEditing_qk_f() -> QKC<AA,YY,ZZ,Void>{
		 self +^ self.value.enableEditing()
	}

	// Record the fact that a change affecting the value returned by -hasUnsavedChanges has occurred. Subclasses should not need to call this if they set the undoManager.
    open func updateChangeCount_qk_f(_ change: UIDocument.ChangeKind) -> QKC<AA,YY,ZZ, UIDocument.ChangeKind>{
		 self +^ self.value.updateChangeCount(change) +^ change
	}

	// The default implementation of updateChangeCountWithToken:forSaveOperation: calls [self updateChangeCount:UIDocumentChangeCleared] if no changes are made during the save.
    open func changeCountToken_qk_f(for saveOperation: UIDocument.SaveOperation) -> QKC<AA,YY,ZZ,Any>{
		 self +^ self.value.changeCountToken(for:saveOperation)
	}

    open func updateChangeCount_qk_f(withToken changeCountToken: Any, for saveOperation: UIDocument.SaveOperation) -> QKC<AA,YY,ZZ, Any>{
		 self +^ self.value.updateChangeCount(withToken:changeCountToken, for:saveOperation) +^ changeCountToken
	}

	// The completion handler is executed on the calling queue.
    open func save_qk_f(to url: URL, for saveOperation: UIDocument.SaveOperation, completionHandler: ((Bool) -> Void)? = nil) -> QKC<AA,YY,ZZ, URL>{
		 self +^ self.value.save(to:url, for:saveOperation, completionHandler:completionHandler) +^ url
	}

	// The default implementation of this method invokes [self hasUnsavedChanges] and, if that returns YES, invokes [self saveToURL:[self fileURL] forSaveOperation:UIDocumentSaveForOverwriting completionHandler:completionHandler].
    open func autosave_qk_f(completionHandler: ((Bool) -> Void)? = nil) -> QKC<AA,YY,ZZ,Void>{
		 self +^ self.value.autosave(completionHandler:completionHandler)
	}

		// For a specified type, and a particular kind of save operation, return a file name extension that can be appended to a base file name.
    open func fileNameExtension_qk_f(forType typeName: String?, saveOperation: UIDocument.SaveOperation) -> QKC<AA,YY,ZZ,String >{
		 self +^ self.value.fileNameExtension(forType:typeName, saveOperation:saveOperation)
	}

	// Because it does several different things, and because the things are likely to change in future releases of iOS, it's probably not a good idea to override this method without invoking super.
    open func writeContents_qk_f(_ contents: Any, andAttributes additionalFileAttributes: [AnyHashable : Any]? = nil, safelyTo url: URL, for saveOperation: UIDocument.SaveOperation) -> QKC<AA,YY,ZZ, Any>{
		 self +^ (try?self.value.writeContents(contents, andAttributes:additionalFileAttributes, safelyTo:url, for:saveOperation)) +^ contents
	}

	// Called by -writeContents:andAttributes:safelyToURL:forSaveOperation:error: to write the data to disk. Override point for subclasses that need access to the on-disk representation of the document while saving.
    open func writeContents_qk_f(_ contents: Any, to url: URL, for saveOperation: UIDocument.SaveOperation, originalContentsURL: URL?) -> QKC<AA,YY,ZZ, Any>{
		 self +^ (try?self.value.writeContents(contents, to:url, for:saveOperation, originalContentsURL:originalContentsURL)) +^ contents
	}

	// The attributes are passed to -writeContents:andAttributes:safelyToURL:forSaveOperation:error: for writing to the file
    open func fileAttributesToWrite_qk_f(to url: URL, for saveOperation: UIDocument.SaveOperation) -> QKC<AA,YY,ZZ,[AnyHashable : Any]?>{
		 self +^ (try?self.value.fileAttributesToWrite(to:url, for:saveOperation))
	}

	// Default implementation calls [self loadFromContents:ofType:error:] on the queue that called openWithCompletionHandler:, or the main queue if called directly, with NSData or NSFileWrapper contents.
    open func read_qk_f(from url: URL) -> QKC<AA,YY,ZZ, URL>{
		 self +^ (try?self.value.read(from:url)) +^ url
	}

	// The default implementations of saveToURL: and openWithCompletionHandler: both use this to serialize file access. Direct calls to reading and writing methods should use this method to serialize file access on a background queue.
    open func performAsynchronousFileAccess_qk_f(_ block: @escaping () -> Void) -> QKC<AA,YY,ZZ,Void>{
		 self +^ self.value.performAsynchronousFileAccess(block)
	}

	// 3. If the userInteractionPermitted flag is NO, you should immediately handle the error and call [self finishedHandlingError:] within the context of -handleError:userInteractionPermitted:
    open func handleError_qk_f(_ error: Error, userInteractionPermitted: Bool) -> QKC<AA,YY,ZZ, Error>{
		 self +^ self.value.handleError(error, userInteractionPermitted:userInteractionPermitted) +^ error
	}

	// If overridden, subclasses must call super
    open func finishedHandlingError_qk_f(_ error: Error, recovered: Bool) -> QKC<AA,YY,ZZ, Error>{
		 self +^ self.value.finishedHandlingError(error, recovered:recovered) +^ error
	}

	// It is only necessary to override this method if you override -handleError:userInteractionPermitted: without calling super
    open func userInteractionNoLongerPermitted_qk_f(forError error: Error) -> QKC<AA,YY,ZZ, Error>{
		 self +^ self.value.userInteractionNoLongerPermitted(forError:error) +^ error
	}

	// Subclasses that override this method must call super or use NSFileCoordinator directly to initiate a coordinated read.
    open func revert_qk_f(toContentsOf url: URL, completionHandler: ((Bool) -> Void)? = nil) -> QKC<AA,YY,ZZ, URL>{
		 self +^ self.value.revert(toContentsOf:url, completionHandler:completionHandler) +^ url
	}

}

extension QKC where AA :UIDocument {
    @available(iOS 8.0, *)
    open func userActivity_qk_s(_ userActivity:  NSUserActivity?) -> QKC<AA,YY,ZZ, NSUserActivity?>{
		return link(next: userActivity).then_QK { $0.value.userActivity = userActivity }
	}
    @available(iOS 8.0, *)
    open func userActivity_qk_g() -> QKC<AA,YY,ZZ, NSUserActivity?>{
		 self +^ self.value.userActivity
	}

    @available(iOS 8.0, *)
    open func updateUserActivityState_qk_f(_ userActivity: NSUserActivity) -> QKC<AA,YY,ZZ, NSUserActivity>{
		 self +^ self.value.updateUserActivityState(userActivity) +^ userActivity
	}

    @available(iOS 8.0, *)
    open func restoreUserActivityState_qk_f(_ userActivity: NSUserActivity) -> QKC<AA,YY,ZZ, NSUserActivity>{
		 self +^ self.value.restoreUserActivityState(userActivity) +^ userActivity
	}

}

